<template>
	<view>
		<!-- #ifndef MP-WEIXIN -->
		<uni-nav-bar v-if="returngoods_id" fixed="true" left-icon="back" :status-bar="true" :border="false" title="购物车"
			class="NavBar" @clickLeft="NavBar()">
			<view slot="left" @click="retur()"></view>
			<view slot="right" @click="cut()" v-if="cart_list.length!=0">{{jiesuOrshanchu?"管理":"完成"}}</view>
		</uni-nav-bar>
		<uni-nav-bar v-else fixed="true" :status-bar="true" :border="false" title="购物车">
			<view slot="left" @click="cut()"></view>
			<view slot="right" @click="cut()" v-if="cart_list.length!=0">{{jiesuOrshanchu?"管理":"完成"}}</view>
		</uni-nav-bar>
		<!-- #endif -->
		<!-- #ifdef MP-WEIXIN -->

		<uni-nav-bar fixed="true" :status-bar="true" :border="false" title="购物车">
			<view slot="left" @click="cut()" v-if="cart_list.length!=0">{{jiesuOrshanchu?"管理":"完成"}}</view>
		</uni-nav-bar>
		<!-- #endif -->
		<view class="view_container">
			<view class="car_box" v-for="(good,index) in cart_list" :key="index">
				<!-- 订单名称 -->
				<view class="dingdan_box">
					<view class="flex_center">
						<image @click.stop="check(index)" v-if="!flag1[index]&&good.physical.physical_id==physical_id"
							class="checkno" src="../../static/images/checkno.png" mode=""></image>
						<image @click.stop="check(index)" v-if="flag1[index]&&good.physical.physical_id==physical_id"
							class="checkyes" src="../../static/images/checkyes.png" mode=""></image>
						<image @click.stop="forbidTip" v-if="good.physical.physical_id!=physical_id" class="checkno"
							src="../../static/images/forbid.png" mode=""></image>
						<image class="store_image" src="../../static/images/car_dianpu.jpg" mode=""></image>
						<text style="font-weight: bold;">{{good.physical.physical_name}}</text>
					</view>
				</view>
				<view v-for="(full,index2) in good.goods" :key="index2">
					<!-- 显示是不是有加价购商品 -->
					<view class="jjg_box" v-if="full.type==1&&full.activity_info!=null"
						@click="ToList(good.store.store_id,full.activity_info.repur_id,1)">
						<view class="jjleft" v-if="full.activity_info.repur_name">
							<text class="jiajiaGood">{{full.activity_info.repur_name}}</text>
						</view>
						<view class="jjcenter">
							<text class="explain">{{full.activity_info.repur_name }}</text>
						</view>
						<view class="jjgright">
							<text>去凑单</text>
							<image src="../../static/images/right_arrow.png" mode=""></image>
						</view>
					</view>
					<view class="jjg_box" v-if="full.type==2&&full.activity_info!=null"
						@click="ToList(good.store.store_id,full.activity_info.renxuan_id,2)">
						<view class="jjleft" v-if="full.activity_info.renxuan_name">
							<text class="jiajiaGood">{{full.activity_info.renxuan_name}}</text>
						</view>
						<view class="jjcenter">
							<text
								class="explain">{{full.activity_info.base_money+'元任选'+full.activity_info.base_num+"件" }}</text>
						</view>
						<view class="jjgright">
							<text>去凑单</text>
							<image src="../../static/images/right_arrow.png" mode=""></image>
						</view>
					</view>
					<view class="jjg_box" v-if="full.type==3&&full.activity_info!=null"
						@click="ToList(good.store.store_id,full.activity_info.mfunjian_id,3)">
						<view class="jjleft" v-if="full.activity_info.mfunjian_name">
							<text class="jiajiaGood">{{full.activity_info.mfunjian_name}}</text>
						</view>
						<view class="jjcenter">
							<text
								class="explain">{{"满"+full.activity_info.buy_num+"件付"+(full.activity_info.buy_num-full.activity_info.reduce_num)+"件" }}</text>
						</view>
						<view class="jjgright">
							<text>去凑单</text>
							<image src="../../static/images/right_arrow.png" mode=""></image>
						</view>
					</view>
					<view class="jjg_box" v-if="full.type==4&&full.activity_info!=null"
						@click="ToList(good.store.store_id,full.activity_info.nzhe_id,4)">
						<view class="jjleft" v-if="full.activity_info.nzhe_name">
							<text class="jiajiaGood">{{full.activity_info.nzhe_name}}</text>
						</view>
						<view class="jjcenter">
							<text class="explain">
								<text style="margin-right: 10rpx;" v-for="(value,_index) in full.activity_info.rule"
									:key="_index">
									第{{_index}}件{{value}}折
								</text>
							</text>
						</view>
						<view class="jjgright">
							<text>去凑单</text>
							<image src="../../static/images/right_arrow.png" mode=""></image>
						</view>
					</view>
					<view class="jjg_box" v-if="full.type==5&&full.activity_info!=null"
						@click="ToList(good.store.store_id,full.activity_info.discount_info.full_id,5)">
						<view class="jjleft" v-if="full.activity_info.full_activity.full_title">
							<text class="jiajiaGood">{{full.activity_info.full_activity.full_title}}</text>
						</view>
						<view class="jjcenter">
							<text class="explain">{{full.activity_info.full_activity.full_desc }}</text>
						</view>
						<view class="jjgright">
							<text>去凑单</text>
							<image src="../../static/images/right_arrow.png" mode=""></image>
						</view>
					</view>

					<view v-for="(item,index3) in full.goods_list" :key="index3" @click="goInfo(item.goods_id)"
						class="">
						<view class="ffkk">
							<view class="ffbox">
								<view @click.stop v-if="item.cart_id!=0&&good.physical.physical_id==physical_id&&item.status!=0">
									<image @click="check_item(index,index2,index3)"
										v-if="!checkList[index][index2][index3]" class="checkno"
										src="../../static/images/checkno.png" mode=""></image>
									<image @click="check_item(index,index2,index3)" v-else class="checkyes"
										src="../../static/images/checkyes.png" mode=""></image>
								</view>
								<view class="" v-if="item.cart_id!=0&&good.physical.physical_id==physical_id&&item.status==0">
									<image @click.stop="forbidTip" class="checkno" src="../../static/images/forbid.png" mode=""></image>
								</view>
								<view class="" v-if="item.cart_id!=0&&good.physical.physical_id!=physical_id">
									<image @click.stop="forbidTip" class="checkno" src="../../static/images/forbid.png"
										mode=""></image>
								</view>
								<view class="checkno" v-if="item.cart_id==0"></view>
								<view class="cartImg">
									<image class="shopCarImg" :src="item.goods_image_url"></image>
									
									<image v-if="item.status==0" class="cartShelf" :src="`${picUrl}/xiajia.png`"></image>
								</view>
								<view class="left_box">
									<view class="oneline">{{item.goods_name}}</view>
									<view class="oneline">{{item.virtual_name}}</view>
									<view class="size" style="height: 44rpx;">
										<text class="font_24" v-for="spec in item.goods_spec" :key="spec"
											v-if="spec!='无'">{{spec}}</text>
										<text v-if="item.bl_goods_list" class="taocanIco">套餐</text>
									</view>
									<view class="shopflex">
										<view>
											<view class="font_24 lh25 color_1">价格：¥ {{item.goods_promotion_price}}</view>
											<!-- <view v-if="Number(item.goods_price) < Number(item.goods_s_price)">
												<view class="font_24 lh25" style="text-decoration: line-through;">原价：¥
													{{item.goods_s_price}}
												</view>
												<view class="font_24 lh25 color_1">促销价：¥ {{item.goods_price}} </view>
											</view>
											<view v-else-if="item.bl_goods_list">
												<view class="font_24 lh25 color_1">价格：¥ {{item.goods_price}}</view>
											</view>
											<view v-else>
												<view class="font_24 lh25 color_1">价格：¥ {{item.goods_s_price}}</view>
											</view> -->
										</view>
										<view class="flexBox">
											<view @click.stop="" class="uni-numbox" v-if="item.cart_id!=0">
												<view class="uni-numbox__value"
													@click="reduce(index,index2,index3,item)">-
												</view>
												<input disabled="true" class="uni-numbox__imput"
													v-model="numberList[index][index2][index3]" type="text" />
												<view class="uni-numbox__valueriht"
													@click="add(index,index2,index3,item)">+
												</view>
											</view>
										</view>
									</view>

								</view>
							</view>
						</view>
					</view>
				</view>
			</view>

			<!-- 购物车 -->
			<view v-if="cart_list.length!=0">
				<view class="bottom">
					<view class="fl bottom1 fs22 C666" style="display: flex;align-items: center;">
						<image @click="check_car()" v-if="!flag2" class="checkno" src="../../static/images/checkno.png">
						</image>
						<image @click="check_car()" v-if="flag2" class="checkyes"
							src="../../static/images/checkyes.png"></image>
						全选
					</view>
					<view class="fl bottom2" style="font-size: 24rpx;">
					</view>
					<view class="fl bottom3" style="font-size: 30rpx;">
						<text class="C333 fs28">合计:</text>
						<text class="fs28 Cff0101" style="color: #ff0101;">¥ {{goods_sum}}</text>
					</view>
					<view v-if="jiesuOrshanchu" class="fl bottom4 fs24" @click="carPay">结算</view>
					<view v-else @click="cartDel()" class="fl bottom4 fs24">删除</view>
				</view>
			</view>
		</view>
		<!-- 领券 -->
		<uni-popup ref="popup" type="bottom" class="popup">
			<view class="popup_box">
				<view class="none" v-if="ticket.length==0" style="text-align: center;font-size: 28rpx;">
					暂时还没有优惠券哦~
				</view>
				<view v-else>
					<view class="popup_title">
						<view></view>
						<view style="font-size: 30rpx;margin-left: 40rpx;">优惠</view>
						<image @click="closePop" class="del" src="../../static/images/del.jpg" mode=""></image>
					</view>
					<view style="margin-left: 20rpx;">领券</view>
					<scroll-view class="ticket_box" scroll-y="true">
						<view class="ticket" v-for="(item,index) in ticket" :key="index"
							@click="ToDeta(item.voucher_t_id)">
							<view class="ticket_reduce Cfe0000">￥{{item.voucher_t_price}}</view>
							<view class="ticketC Cfe0000" v-if="item.voucher_t_range==0">全场通用</view>
							<view class="ticketC Cfe0000" v-if="item.voucher_t_range==1">商品优惠券</view>
							<view class="ticketC Cfe0000" v-if="item.voucher_t_range==2">限品类券</view>

							<view class="ticketN Cfe0000" v-if="item.voucher_t_range==0">全场通用</view>
							<view class="ticketN Cfe0000" v-if="item.voucher_t_range==1">{{item.goods_name}}</view>
							<view class="ticketN Cfe0000" v-if="item.voucher_t_range==2">{{item.gc_name}}</view>
							<view class="ticket_limt Cfe0000">满{{item.voucher_t_limit}}可用</view>
							<view class="ticket_time Cfe0000">有效期：{{item.voucher_t_end_date_format}}</view>
							<view class="ticketX Cfe0000">详细信息<image src="/static/images/yhqIco.png" mode=""></image>
							</view>
							<view class="ticket_user" @click.stop="get_ticket(item.voucher_t_id)"
								v-if="!item.has_exchange">立即领取</view>
							<image v-else class="ticket_image" src="../../static/images/hasgot.png" mode=""></image>
						</view>
					</scroll-view>
				</view>
				<button class="ticket_button" @click="closePop">完成</button>
			</view>
		</uni-popup>
		<view class="kkry" v-if="cart_list.length==0">
			<image src="../../static/images/kkry.png"></image>
			<view>购物车空空如也，去逛逛吧~</view>
			<view class="Toshop" @click="Toshop()">去逛逛</view>
		</view>

		<view style="height: 80rpx;"></view>

	</view>
</template>

<script>
	import uniPopup from '@/components/uni-popup/uni-popup.vue'
	import uniNavBar from '@/components/uni-nav-bar/uni-nav-bar.vue'
	export default {
		components: {
			uniNavBar,
			uniPopup
		},
		data() {
			return {
				card_type: ['商城', '全球购'],
				right_text: '管理',
				checkList: [],
				del_list: [],
				numberList: [],
				goods_id: [],
				goods_sum: 0,
				price: [],
				cate_id: [],
				jiesuan: 0,
				money1: 20.5,
				money2: 20.5,
				number: 0,
				flag1: [],
				flag2: false,
				flag3: [],
				flag4: false,
				flag5: false,
				maskFlag: false,
				whethergot1: false,
				whethergot3: false,
				whethergot2: false,
				jiesuOrshanchu: true,
				money: 10.00,
				cart_list: [],
				is_global: 0,
				is_applet: false,
				ticket: [],
				ture_car_id: [], //选中的商品ID
				goodssum: "", //购物车商品总价
				activityTtpe: [], //活动类型
				activityId: [], //活动ID
				StringcarID: [],
				returngoods_id: "",
				storeid: "",
				physical_id: ""
			}
		},
		computed: {
			Fixed() {
				return this.goods_sum.toFixed(2)
			}
		},
		watch: {
			Fixed(val) {
				this.goods_sum = Number(val)
			}
		},
		created() {
			this.isWeiXin()
		},

		onShow() {
			this.jiesuOrshanchu = true;
			this.getInfo()
		},
		onLoad(e) {
			if (uni.getStorageSync("goods_id")) {
				this.returngoods_id = uni.getStorageSync("goods_id");
				uni.removeStorageSync('goods_id');
			}
		},
		onHide() {
			this.returngoods_id = ""
		},
		methods: {
			//禁止提示
			forbidTip() {
				uni.showToast({
					icon: "none",
					title: "禁止勾选操作，请去切换门店！",
					duration: 2000
				})
			},
			ToDeta(voucher_id) {
				uni.navigateTo({
					url: "/operation/voucher/info?voucher_id=" + voucher_id + "&type=1"
				})
			},
			Toshop() { //去逛逛
				uni.switchTab({
					url: "/main/home/index"
				})
			},
			NavBar() { //返回

				uni.reLaunch({
					url: "/mall/goods/info?goods_id=" + this.returngoods_id + "&isreturn=1"
				});
			},
			ToList(store_id, activityId, type) { //去凑单 type 1加价购 2N元任选 3M件付N件 4N件折 5满额满减
				switch (type) {
					case 3:
						uni.navigateTo({
							url: '/operation/pages/activity/collectBills?store_id=' + store_id + '&mfunjian_id=' +
								activityId
						})
						break;
					case 2:
						uni.navigateTo({
							url: '/operation/NOptional/list?store_id=' + store_id + '&renxuan_id=' + activityId
						})
						break;
					case 4:
						uni.navigateTo({
							url: "/operation/pages/activity/collectBills?store_id=" + store_id + '&nzhe_id=' +
								activityId
						})
						break;
					case 5:
						uni.navigateTo({
							url: '/operation/pages/activity/collectBills?store_id=' + store_id + '&full_id=' +
								activityId
						})
						break;
					case 1:
						uni.navigateTo({
							url: '/operation/repurchase/list?store_id=' + store_id + '&repur_id=' + activityId
						})
						break;
				}
			},
			//判断是不是微信小程序
			isWeiXin() {
				// #ifdef MP-WEIXIN
				this.is_applet = true
				// #endif
			},
			//去店铺
			goStore(id) {
				uni.navigateTo({
					url: '../store/store?store_id=' + id
				})
			},
			//关闭领券
			closePop() {
				this.$refs.popup.close()
			},
			//显示购物车购物券
			showPop(id) {
				this.storeid = id
				this.$refs.popup.open()
				this.$util.request({
					url: '/mobile/index.php?act=pointvoucher&op=store_voucher',
					data: {
						store_id: id
					}
				}).then((res) => {
					this.ticket = res.datas.vouchers
				})
			},
			//跳转到详情页面
			goInfo(goods_id) {
				uni.navigateTo({
					url: '/mall/goods/info?goods_id=' + goods_id,
				})
			},
			//切换到删除面板
			cut() {
				this.jiesuOrshanchu = !this.jiesuOrshanchu
				if (this.jiesuOrshanchu) {
					this.right_text = '管理'
				} else {
					this.right_text = '完成'
				}
			},
			//结算
			carPay() {
				if (this.goods_sum > 0) {
					let id = []
					for (let i = 0; i < this.checkList.length; i++) {
						for (let j = 0; j < this.checkList[i].length; j++) {
							for (let k = 0; k < this.checkList[i][j].length; k++) {
								if (this.checkList[i][j][k]) {
									id.push(this.cate_id[i][j][k] + '|' + this.numberList[i][j][k])
								}
							}
						}
					}
					id = id.join(',')
					console.log(typeof(id), id)
					uni.navigateTo({
						url: '/mall/order/confirm?cart_id=' + id + '&ifcart=' + 1 + "&is_global=" + this.is_global
					})
				} else {
					uni.showToast({
						title: '请选择需要结算的商品！',
						icon: 'none'
					})
				}
			},
			//购物车数量减
			reduce(x, y, z, item) {
				if (this.numberList[x][y][z] > 1) {
					this.numberList[x][y].splice(z, 1, Number(this.numberList[x][y][z]) - 1)
					let e = this.numberList[x][y][z]
					this.shopCarNmb(e, item, x, y, z, 1)
				} else {
					this.cartDel(item.cart_id)
				}
			},
			add(x, y, z, item) {
				if (Number(this.numberList[x][y][z]) + 1 > item.goods_storage) {
					uni.showToast({
						title: '库存不足！',
						icon: 'none'
					})
				} else {
					this.numberList[x][y].splice(z, 1, Number(this.numberList[x][y][z]) + 1)
					let e = this.numberList[x][y][z]
					this.shopCarNmb(e, item, x, y, z, 2)
				}
			},
			//更改购物车购买数量
			shopCarNmb(e, item, x, y, z, type) {
				this.$util.request({
					url: '/mobile/index.php?act=member_cart&op=cart_edit_quantity',
					method: 'POST',
					data: {
						cart_id: item.cart_id,
						quantity: e
					}
				}).then(res => {
					this.price[x][y].splice(z, 1, res.datas.total_price)
					if (this.checkList[x][y][z]) {
						this.Is_check(x, y, z)
					}
				})
			},
			//获取购物车列表
			getInfo() {
				this.$util.request({
					// url: '/mobile/index.php?act=member_cart&op=cart_list',
					url: "/mobile/index.php?act=member_cart&op=cart_list_v2",
					data: {
						is_global: this.is_global
					}
				}).then(res => {
					console.log('获取购物车列表', res)
					if (this.cart_list == res.datas.cart_list) {
						return true
					}
					this.physical_id = uni.getStorageSync("physical_id")
					this.checkList = [] //选择
					this.numberList = [] //数量
					this.del_list = [] //删除
					this.flag1 = []
					this.flag3 = []
					this.cate_id = []
					this.price = [] //价格
					this.goods_id = [] //商品Id
					this.flag2 = false
					this.flag4 = false
					this.goods_sum = 0.00 //总价
					this.activity_info = [] //活动信息
					if (res.error_code == '2830001') {
						this.cart_list = []
						return false
					}
					this.cart_list = res.datas.cart_list
					this.goodssum = res.datas.sum
					for (let i = 0; i < this.cart_list.length; i++) { //循环店铺
						this.cart_list[i].select = true
						this.checkList.push([])
						this.numberList.push([])
						this.price.push([])
						this.del_list.push([])
						this.cate_id.push([])
						this.goods_id.push([])
						this.activity_info.push([])
						this.flag1.push(false)
						this.flag3.push(false)
						
						for (let j = 0; j < this.cart_list[i].goods.length; j++) { //循环店铺活动
							this.checkList[i].push([])

							this.numberList[i].push([])
							this.price[i].push([])
							this.del_list[i].push([])
							this.cate_id[i].push([])
							this.goods_id[i].push([])

							this.activity_info[i].push(this.cart_list[i].goods[j].activity_info) //活动信息
							if (this.activity_info[i][j]) {
								this.activity_info[i][j].type = this.cart_list[i].goods[j].type //活动类型
							}

							for (let k = 0; k < this.cart_list[i].goods[j].goods_list.length; k++) { //循环每个商品
								this.cart_list[i].goods[j].goods_list.forEach(v => {
									v.selected = true
								})
								this.checkList[i][j].push(false)
								this.del_list[i][j].push(false)
								this.goods_id[i][j].push(this.cart_list[i].goods[j].goods_list[k].goods_id)
								this.cate_id[i][j].push(this.cart_list[i].goods[j].goods_list[k].cart_id) //购物车id
								this.numberList[i][j].push(this.cart_list[i].goods[j].goods_list[k]
									.goods_num) //商品数量
								this.price[i][j].push(this.cart_list[i].goods[j].goods_list[k].goods_sum) //价格
							}
						}
					}
					this.goods_sum = 0
				})
			},
			Is_check(x, y, z) { //选中的商品购物车ID  结算总价
				this.StringcarID = [];
				this.ture_car_id = [];
				this.activityTtpe = [];
				this.activityId = [];
				for (let i = 0; i < this.checkList.length; i++) {
					this.ture_car_id.push([])
					this.activityTtpe.push([])
					this.activityId.push([])
					for (let j = 0; j < this.checkList[i].length; j++) {
						if (this.activity_info[i][j] != null) {
							this.activityTtpe[i].push(this.activity_info[i][j].type) //活动类型
							if (this.activity_info[i][j].type == 5) {
								this.activityId[i].push(this.activity_info[i][j].discount_info.full_id)
							} else if (this.activity_info[i][j].type == 1) {
								this.activityId[i].push(this.activity_info[i][j].repur_id)
							}
						} else {
							this.activityId[i].push(0) //活动id
							this.activityTtpe[i].push(0) //活动类型
						}
						this.ture_car_id[i].push([])
						for (let k = 0; k < this.checkList[i][j].length; k++) {
							if (this.checkList[i][j][k] && this.cate_id[i][j][k] != undefined) {
								this.StringcarID.push(this.cate_id[i][j][k]);
								this.ture_car_id[i][j].push(this.cate_id[i][j][k])
							}
						}
					}
				}

				this.StringcarID = this.StringcarID.length > 0 ? this.StringcarID.join(",") : 0; //选中的购物车Id 用逗号隔开


				if (this.StringcarID != 0) {
					this.$util.request({
						url: '/mobile/index.php?act=member_cart&op=cart_select_change',
						method: 'get',
						data: {
							cart_id: this.StringcarID,
							is_global: this.is_global,
						}
					}).then(res => {
						this.goods_sum = 0
						if (res.error_code == 0) {
							this.goods_sum = Number(res.datas.sum);
						}
						return false;
					})
				} else {
					this.goods_sum = 0;
					return false;
				}
			},
			//删除购物车内商品
			cartDel(DelId) {
				let id = []
				for (let i = 0; i < this.checkList.length; i++) {
					for (let j = 0; j < this.checkList[i].length; j++) {
						for (let k = 0; k < this.checkList[i][j].length; k++) {
							if (this.checkList[i][j][k] && this.cate_id[i][j][k]) {
								id.push(this.cate_id[i][j][k])
							}
						}
					}
				}
				if (DelId) {
					id = DelId
				} else {
					id = id.join('|')
				}
				// console.log(id)
				if (!id) {
					uni.showToast({
						title: '请选择要删除的商品！',
						icon: 'none'
					})
					return false
				}

				uni.showModal({
					title: '提示',
					content: '是否删除购物车商品？',
					success: (res2) => {
						if (res2.confirm) {
							this.$util.request({
								url: '/mobile/index.php?act=member_cart&op=cart_del',
								method: 'POST',
								data: {
									cart_id: id
								}
							}).then(res => {
								if (res.datas == '1') {
									uni.showToast({
										title: '删除成功！'
									})
									this.goods_sum = 0.00
									this.getInfo();
								}
							})
						} else if (res2.cancel) {

						}
					}
				})


			},
			//全选
			check(index) {
				//购买选择
				if (this.flag1[index]) {
					this.flag1[index] = !this.flag1[index]
					this.checkList[index].map((item, dot) => {
						let src = []
						item.map(() => {
							src.push(false)
						})
						this.checkList[index].splice(dot, 1, src)
					})
					this.Is_check();
				} else {
					//全选呗
					this.flag1[index] = !this.flag1[index]
					this.checkList[index].map((item, dot) => {
						let src = []
						item.map((value) => {
							src.push(true)
						})
						this.checkList[index].splice(dot, 1, src)
					})
					this.check_car()
					console.log('1111111111', this.flag2)
				}
				this.Is_check();
				this.fund(false)
			},
			//购物车全选
			check_car() {
				this.checkList.map((arr, index) => {
					arr.map((item, index2) => {
						item.map((data, index3) => {
							//取消全选
							if (this.flag2) {
								this.goods_sum = 0
								this.flag1.splice(index, 1, false)
								item.splice(index3, 1, false)
							} else {
								//全选
								this.flag1.splice(index, 1, true)
								item.splice(index3, 1, true)
							}
						})
					})
				})
				this.flag2 = !this.flag2
				this.Is_check();
			},
			//店铺下商品
			check_item(x, y, z, aplay) {
				if (aplay) {
					//删除选择
					let count = 0,
						count2 = 0;
					this.del_list[x][y].splice(z, 1, !this.del_list[x][y][z])
					this.del_list[x].map(arr => {
						arr.map(item => {
							if (item == false) {
								this.flag3[x] = false
							} else {
								count++
							}
							count2++
						})
					})
					if (count == count2) {
						this.flag3.splice(x, 1, true)
					}
					this.fund(true)
				} else {
					//选择结算商品
					let count = 0,
						count2 = 0;
					this.checkList[x][y].splice(z, 1, !this.checkList[x][y][z])
					this.checkList[x].map(arr => {
						arr.map(item => {
							if (item == false) {
								this.flag1[x] = false
							} else {
								count++
							}
							count2++
						})
					})
					if (count == count2) {
						this.flag1.splice(x, 1, true)
						this.check_car()
					}
					//计算价格z
					this.Is_check(x, y, z)
					this.fund(false)
				}
			},
			fund(type) {
				let count2 = 0;
				if (type) {
					console.log(this.flag3)
					this.flag3.map(item => {
						if (item) {
							count2++
						} else {
							this.flag4 = false
						}
					})
					if (count2 == this.flag3.length) {
						this.flag4 = true
					}
				} else {
					this.flag1.map(item => {
						if (item) {
							count2++
						} else {
							this.flag2 = false
						}
					})
					if (count2 == this.flag1.length) {
						this.flag2 = true
					}
				}
			},
			//领取优惠券
			get_ticket(id) {
				let that = this;
				this.$util.request({
					url: '/mobile/index.php?act=pointvoucher&op=voucherexchange_save',
					data: {
						vid: id
					},
					method: 'post'
				}).then(res => {
					if (res.error_code == 0) {
						uni.showToast({
							title: "领取成功",
							icon: "success"
						})
						this.showPop(that.storeid)
					} else {
						uni.showToast({
							title: res.message,
							icon: "none"
						})
					}
				})
			},
			//结算数量
			goods_total() {
				for (let i = 0; i < this.checkList.length; i++) {
					for (let j = 0; j < this.checkList[i].length; j++) {
						if (this.checkList[i]) {}
					}
				}
			}
		}
	}
</script>

<style scoped lang="scss">
	.Toshop {
		width: 300rpx;
		line-height: 70rpx;
		margin: 30rpx auto;
		border: 1px solid #999999;
		border-radius: 20rpx;
	}

	.taocanIco {
		margin-left: 10rpx;
		background-color: #ff4300;
		color: #FFFFFF;
		line-height: 26rpx;
		padding: 0 10rpx;
		border-radius: 10rpx;
	}

	.lh25 {
		line-height: 25rpx;
	}

	.store_image {
		width: 40upx;
		height: 40upx;
		margin-right: 10rpx;
	}

	.flex_center {
		display: flex;
		align-items: center;
	}

	.zengpin {
		padding: 0rpx;
		border-radius: 5px;
		color: #ffffff;
		background-color: #ff4300;
		font-size: 26rpx;
		margin-right: 20rpx;
		text-align: center;
		width: 100rpx;
	}

	.ffkk {
		padding: 20rpx 0;
	}

	.ffbox {
		display: flex;
		align-items: center;
		width: 100%;
	}

	.premiums {
		padding: 20rpx 0 20rpx 50rpx;
		display: flex;
		align-items: center;
	}

	.premiums .font_24 {
		display: block;
		width: 100rpx;
		background-color: #ff9642;
		border-radius: 5rpx;
		text-align: center;
		color: #fff;
	}

	.kkry view {
		font-size: 30rpx;
		color: #333333;
	}

	.kkry {
		text-align: center;
		height: 400rpx;
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		margin: auto;
	}

	.kkry image {
		width: 160rpx;
		height: 160rpx;
	}

	.jjg_box {
		display: flex;
		align-items: center;
		justify-content: space-between;
		display: flex;
		align-items: center;
		padding-top: 20rpx;
		border-top: 1rpx solid #ccc;
	}

	.jjg_box .jjleft {
		display: flex;
		font-size: 26rpx;
		/* padding-left: 30rpx; */
		color: #333333;
		margin-right: 20rpx;
		max-width: 150rpx;
		text-overflow: ellipsis;
		overflow: hidden;
		white-space: nowrap;
	}

	.jjg_box .jjcenter {
		width: 390rpx;
		white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.jjg_box .jjgright {
		display: flex;
		align-items: center;
		font-size: 26rpx;
		color: red;
	}

	.jjg_box .jjgright image {
		height: 25rpx;
		width: 15rpx;
		margin-left: 20rpx;
	}

	.jiajiaGood {
		background: linear-gradient(to bottom right, #FA082A, #FF9642);
		border-radius: 10rpx;
		color: #FFFFFF;
		font-size: 24rpx;
		padding: 4rpx 8rpx;
		margin-right: 10rpx;
		height: 36rpx;
		line-height: 36rpx;
		max-width: 122rpx;
		overflow: hidden;
		text-overflow: ellipsis;
	}

	.jiajiagou {
		color: #FA082A;
		border-radius: 10rpx;
		border: 1rpx solid #FA082A;
		font-size: 24rpx;
		padding: 4rpx 10rpx;
		margin-right: 8rpx;
	}

	.qqgou {
		background: linear-gradient(to bottom right, #FA0878, #CE51E4);
		border-radius: 10rpx;
		color: #FFFFFF;
		font-size: 24rpx;
		padding: 4rpx 8rpx;
		margin-right: 10rpx;
	}

	.shop_type {
		color: #ff4300;
		border-bottom: 1rpx solid #ff4300;
	}

	.card_type {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 95rpx;
		line-height: 95rpx;
		/* position: fixed;width: 100%; */
	}

	.card_type>view {
		font-size: 32rpx;
		width: 120rpx;
		text-align: center;
	}

	.card_type>view:first-child {
		margin-right: 40rpx;
	}

	.view_container {
		/* #ifdef H5 */
		padding-bottom: 200rpx;
		/* #endif */
	}

	.uni-numbox {
		display: flex;
	}

	.uni-numbox__value {
		width: 50rpx;
		height: 50rpx;
		background: #FFFFFF;
		border-radius: 5rpx 0rpx 0rpx 5rpx;
		opacity: 1;
		border: 2rpx solid #494747;
		text-align: center;
	}

	.uni-numbox__valueriht {
		width: 50rpx;
		height: 50rpx;
		background: #FFFFFF;
		border-radius: 0rpx 5rpx 5rpx 0rpx;
		opacity: 1;
		border: 2rpx solid #494747;
		text-align: center;
	}

	.uni-numbox__imput {
		width: 50rpx;
		height: 50rpx;
		background: #FFFFFF;
		border-top: 2rpx solid #494747;
		border-bottom: 2rpx solid #494747;
		text-align: center;
	}

	.car_box:last-child {
		margin-bottom: 0;
	}

	.bottom {
		position: fixed;
		bottom: 0;
		/* #ifdef H5 */
		bottom: 100rpx;
		/* #endif */
		left: 0;
		width: 100%;
		box-sizing: border-box;
		height: 100upx;
		line-height: 100upx;
		background-color: #fff;
		padding: 20upx 20upx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		align-items: center;
		z-index:10;
	}

	.bottom1 {
		/* position: relative;
		top: -8upx; */
	}

	.bottom4 {
		width: 170upx;
		height: 70upx;
		line-height: 70upx;
		background-color: #ff4300;
		text-align: center;
		border-radius: 35upx;
		color: #FFFFFF;
	}

	/*  */
	.carMask {
		position: fixed;
		width: 100%;
		height: 100%;
		left: 0;
		top: 0;
		background-color: rgba(0, 0, 0, 0.3);
		z-index: 100000;
	}

	.maskTop {
		padding-top: 33upx;
	}

	.del {
		width: 44upx;
		height: 44upx;
		margin-right: 20rpx;
	}

	.uni-popup {
		z-index: 999;
	}

	.ticket {
		position: relative;
		width: 710upx;
		height: 232upx;
		background: url(/static/images/yhgbg.png) no-repeat;
		background-size: 100% 100%;
		margin-bottom: 30rpx;
	}

	.ticket_time {
		position: absolute;
		bottom: 30rpx;
		left: 40rpx;
		font-size: 26rpx;
	}

	.ticket_reduce {
		position: absolute;
		top: 52rpx;
		left: 90rpx;
		font-size: 70rpx;
		font-weight: bold;
	}

	.ticket_button {
		margin: 50rpx auto 20rpx;
		color: #FFFFFF;
		background-color: #BE024F;
		border-radius: 20rpx;

	}

	.ticket_limt {
		position: absolute;
		top: 100rpx;
		right: 254rpx;
	}

	.ticket_image {
		width: 110rpx;
		height: 110rpx;
		position: absolute;
		right: 36rpx;
		top: 54rpx;
	}

	.ticket_user {
		position: absolute;
		right: 20rpx;
		top: 90rpx;
		color: #ffffff;
		border: 1rpx solid #ffffff;
		border-radius: 50px;
		font-size: 24rpx;
		padding: 0rpx 20rpx;
	}

	.finished {
		margin: 40upx auto;
		width: 710upx;
		height: 100upx;
		line-height: 100upx;
		background-color: #ff4300;
		color: #FFFFFF;
		font-weight: bold;
		font-size: 32upx;
		text-align: center;
		border-radius: 50upx;
		position: absolute;
		bottom: 0;
		left: 20rpx;
	}

	.yilingqu {
		width: 125upx;
		height: 50upx;
		line-height: 50upx;
		text-align: center;
		border: 1px solid #ff4300;
		margin: 32upx auto;
	}

	.yilingqu2 {
		width: 125upx;
		height: 50upx;
		margin: 32upx auto;
		border: 1px solid #FFFFFF;
	}

	.car_box {
		margin: 20rpx 20rpx 0;
		padding: 10rpx 20rpx;
		background-color: #FFFFFF;
		border-radius: 20rpx;
	}

	.shixiao {
		height: 34rpx;
		width: 60rpx;
		margin-left: -10rpx;
		background-color: #aaaaaa;
		color: #FFFFFF;
		line-height: 34rpx;
		text-align: center;
		border-radius: 10rpx;
		margin-right: 10rpx;
	}

	.twoline {
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 2;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
	}

	.oneline {
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
	}

	.tag {
		color: #fff;
		background-image: linear-gradient(to right, #f91d70, #ff4300);
		padding: 2rpx 5rpx;
		font-size: 24rpx;
	}

	.m-r-20 {
		margin-right: 20rpx;
	}

	.decoration {
		text-decoration: line-through;
	}

	.left_box {
		margin-top: -20rpx;
		margin-left: 20rpx;
		height: 190rpx;
		width: 400rpx;
		padding-right: 10rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}

	.left_box .size {
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		text-overflow: ellipsis;
	}

	.color_1 {
		color: #E96A1D;
	}

	.color2 {
		color: #c8406e;
	}

	.font_24 {
		font-size: 24rpx;
	}

	.checkno {
		margin-right: 25rpx;
		width: 34upx;
		height: 34upx;
	}

	.checkyes {
		padding-right: 25upx;
		width: 34upx;
		height: 34upx;
	}

	.dingdan_box {
		display: flex;
		align-items: center;
		justify-content: space-between;
		/* border-bottom: 1rpx solid #F0F0F0; */
	}
	
	.cartImg{
		position: relative;
	}

	.shopCarImg {
		width: 188upx;
		height: 188upx;
		border-radius: 10upx;
		z-index: 1;
	}
	.cartShelf {
		width: 188upx;
		height: 50upx;
		// border-radius: 10upx;
		position: absolute;
		top: 141upx;
		left: 0;
		z-index: 2;
		// background: rgba(0,0,0,.3);
	}

	.popup_box {
		background-color: #FFFFFF;
		padding: 20rpx;
	}

	.popup_box .popup_title {
		display: flex;
		justify-content: space-between;
	}

	.popup_box .ticket_box {
		height: 100%;
		max-height: 700rpx;
		overflow: auto;
		margin-bottom: 50rpx;
	}

	.flexBox {
		display: flex;
		justify-content: space-between;
		/* width: 100%; */
	}

	.delete {
		padding: 0 20rpx;
		background-color: #ff4300;
		border-radius: 10rpx;
		color: #FFFFFF;
	}

	.ticketN {
		z-index: 10;
		position: absolute;
		font-size: 24upx;
		left: 325upx;
		top: 115upx;
		color: #ff4300;
		padding: 0 10rpx;
		line-height: 30rpx;
		width: 150rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.ticketC {
		z-index: 10;
		position: absolute;
		font-size: 24upx;
		left: 334upx;
		top: 75upx;
		border: 1rpx solid #ff4300;
		color: #ff4300;
		padding: 0 10rpx;
		line-height: 30rpx;
		border-radius: 20rpx;
	}

	.ticketX {
		z-index: 10;
		position: absolute;
		font-size: 24upx;
		color: #666666;
		left: 324upx;
		top: 160upx;
	}

	.ticketX image {
		width: 35rpx;
		height: 35rpx;
		margin-bottom: -6rpx;
		margin-left: 5rpx;
	}

	.Cfe0000 {
		color: #ff4300;
	}

	.shopflex {
		height: 50rpx;
		display: flex;
		justify-content: space-between;
		align-items: center;
	}
</style>